package com.xmy.cultivate.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.xmy.cultivate.entity.OrderApply;
import com.xmy.cultivate.entity.Staff;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * <p>
 * 员工 Mapper 接口
 * </p>
 *
 * @author min
 * @since 2022-07-26
 */
public interface StaffMapper extends BaseMapper<Staff> {

    @Select("SELECT * FROM staff where id=#{id} and deleted =0")
    @Results({
            @Result(column = "id",property = "id"),
            @Result(
                    property = "adminObj",
                    column ="admin_id",
                    one = @One(select = "com.xmy.cultivate.mapper.AdminMapper.selectById")
            )
    })
    public abstract Staff findOneById(@Param("id") Long id);


    @Select("SELECT * FROM staff ${ew.customSqlSegment}")
    @Results({
            @Result(column = "id",property = "id"),
            @Result(
                    property = "adminObj",
                    column ="admin_id",
                    one = @One(select = "com.xmy.cultivate.mapper.AdminMapper.selectById")
            )
    })
    public abstract IPage<Staff> findAll(IPage<?> page, @Param(Constants.WRAPPER) Wrapper wrapper);
}
